examples: Clean up the standalone Makefiles
authorEmmanuele Bassi <ebassi@gnome.org>
Tue, 19 May 2015 15:14:49 +0000 (16:14 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Tue, 26 May 2015 17:01:39 +0000 (18:01 +0100)
Do not hardcode GCC as the compiler; use $(shell) expansion instead of
backticks; split the built source into its own variable.

examples/application1/Makefile.example
examples/application10/Makefile.example
examples/application2/Makefile.example
examples/application3/Makefile.example
examples/application4/Makefile.example
examples/application5/Makefile.example
examples/application6/Makefile.example
examples/application7/Makefile.example
examples/application8/Makefile.example
examples/application9/Makefile.example

index 7b99cb56a1dfe90cd31e4584d3457975edf6b02d..ffab3d434e4fc70831e31cae68560a24379f6fa4 100644 (file)
@@ -1,7 +1,7 @@
-CC = gcc
+CC ?= gcc
 PKGCONFIG = $(shell which pkg-config)
-CFLAGS = `$(PKGCONFIG) --cflags gtk+-3.0`
-LIBS = `$(PKGCONFIG) --libs gtk+-3.0`
+CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
+LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
 
 SRC = main.c exampleapp.c exampleappwin.c
 
index 0561f77ca85046bff0913537cc8149257a7b523f..917e3c70f0cc0cef91fd5e27a56ec41d72a18218 100644 (file)
@@ -1,13 +1,14 @@
-CC = gcc
+CC ?= gcc
 PKGCONFIG = $(shell which pkg-config)
-CFLAGS = `$(PKGCONFIG) --cflags gtk+-3.0`
-LIBS = `$(PKGCONFIG) --libs gtk+-3.0`
-GLIB_COMPILE_RESOURCES = `$(PKGCONFIG) --variable=glib_compile_resources gio-2.0`
-GLIB_COMPILE_SCHEMAS = `$(PKGCONFIG) --variable=glib_compile_schemas gio-2.0`
+CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
+LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
+GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
+GLIB_COMPILE_SCHEMAS = $(shell $(PKGCONFIG) --variable=glib_compile_schemas gio-2.0)
 
-SRC = resources.c exampleapp.c exampleappwin.c exampleappprefs.c main.c
+SRC = exampleapp.c exampleappwin.c exampleappprefs.c main.c
+BUILT_SRC = resources.c
 
-OBJS = $(SRC:.c=.o)
+OBJS = $(BUILT_SRC:.c=.o) $(SRC:.c=.o)
 
 all: exampleapp
 
@@ -29,6 +30,6 @@ exampleapp: $(OBJS) gschemas.compiled
 clean:
        rm -f org.gtk.exampleapp.gschema.valid
        rm -f gschemas.compiled
-       rm -f resources.c
+       rm -f $(BUILT_SRC)
        rm -f $(OBJS)
        rm -f exampleapp
index f3d175f4b0631fb04f909eea17a805d24ab5bea5..c6f82933cc0f9fca5095ada5c58257356b12b128 100644 (file)
@@ -1,12 +1,13 @@
-CC = gcc
+CC ?= gcc
 PKGCONFIG = $(shell which pkg-config)
-CFLAGS = `$(PKGCONFIG) --cflags gtk+-3.0`
-LIBS = `$(PKGCONFIG) --libs gtk+-3.0`
-GLIB_COMPILE_RESOURCES = `$(PKGCONFIG) --variable=glib_compile_resources gio-2.0`
+CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
+LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
+GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
 
-SRC = resources.c exampleapp.c exampleappwin.c main.c
+SRC = exampleapp.c exampleappwin.c main.c
+BUILT_SRC = resources.c
 
-OBJS = $(SRC:.c=.o)
+OBJS = $(BUILT_SRC:.c=.o) $(SRC:.c=.o)
 
 all: exampleapp
 
@@ -20,6 +21,6 @@ exampleapp: $(OBJS)
        $(CC) -o $(@F) $(LIBS) $(OBJS)
 
 clean:
-       rm -f resources.c
+       rm -f $(BUILT_SRC)
        rm -f $(OBJS)
        rm -f exampleapp
index f3d175f4b0631fb04f909eea17a805d24ab5bea5..c6f82933cc0f9fca5095ada5c58257356b12b128 100644 (file)
@@ -1,12 +1,13 @@
-CC = gcc
+CC ?= gcc
 PKGCONFIG = $(shell which pkg-config)
-CFLAGS = `$(PKGCONFIG) --cflags gtk+-3.0`
-LIBS = `$(PKGCONFIG) --libs gtk+-3.0`
-GLIB_COMPILE_RESOURCES = `$(PKGCONFIG) --variable=glib_compile_resources gio-2.0`
+CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
+LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
+GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
 
-SRC = resources.c exampleapp.c exampleappwin.c main.c
+SRC = exampleapp.c exampleappwin.c main.c
+BUILT_SRC = resources.c
 
-OBJS = $(SRC:.c=.o)
+OBJS = $(BUILT_SRC:.c=.o) $(SRC:.c=.o)
 
 all: exampleapp
 
@@ -20,6 +21,6 @@ exampleapp: $(OBJS)
        $(CC) -o $(@F) $(LIBS) $(OBJS)
 
 clean:
-       rm -f resources.c
+       rm -f $(BUILT_SRC)
        rm -f $(OBJS)
        rm -f exampleapp
index 6a7f46be87650b30c8d69aa4fddfff26dcc397ed..97b2265930be27e18f8fab144ede8526352cba54 100644 (file)
@@ -1,12 +1,13 @@
-CC = gcc
+CC ?= gcc
 PKGCONFIG = $(shell which pkg-config)
-CFLAGS = `$(PKGCONFIG) --cflags gtk+-3.0`
-LIBS = `$(PKGCONFIG) --libs gtk+-3.0`
-GLIB_COMPILE_RESOURCES = `$(PKGCONFIG) --variable=glib_compile_resources gio-2.0`
+CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
+LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
+GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
 
-SRC = resources.c exampleapp.c exampleappwin.c main.c
+SRC = exampleapp.c exampleappwin.c main.c
+BUILT_SRC = resources.c
 
-OBJS = $(SRC:.c=.o)
+OBJS = $(BUILT_SRC:.c=.o) $(SRC:.c=.o)
 
 all: exampleapp
 
@@ -20,6 +21,6 @@ exampleapp: $(OBJS)
        $(CC) -o $(@F) $(LIBS) $(OBJS)
 
 clean:
-       rm -f resources.c
+       rm -f $(BUILT_SRC)
        rm -f $(OBJS)
        rm -f exampleapp
index ecfbe2947302ce5dbd824f9080643d6b09f5f371..e667ebf9600329eefcbbf500452fc9faf06d9f9b 100644 (file)
@@ -1,13 +1,14 @@
-CC = gcc
+CC ?= gcc
 PKGCONFIG = $(shell which pkg-config)
-CFLAGS = `$(PKGCONFIG) --cflags gtk+-3.0`
-LIBS = `$(PKGCONFIG) --libs gtk+-3.0`
-GLIB_COMPILE_RESOURCES = `$(PKGCONFIG) --variable=glib_compile_resources gio-2.0`
-GLIB_COMPILE_SCHEMAS = `$(PKGCONFIG) --variable=glib_compile_schemas gio-2.0`
+CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
+LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
+GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
+GLIB_COMPILE_SCHEMAS = $(shell $(PKGCONFIG) --variable=glib_compile_schemas gio-2.0)
 
-SRC = resources.c exampleapp.c exampleappwin.c main.c
+SRC = exampleapp.c exampleappwin.c main.c
+BUILT_SRC = resources.c
 
-OBJS = $(SRC:.c=.o)
+OBJS = $(BUILT_SRC:.c=.o) $(SRC:.c=.o)
 
 all: exampleapp
 
@@ -29,6 +30,6 @@ exampleapp: $(OBJS) gschemas.compiled
 clean:
        rm -f org.gtk.exampleapp.gschema.valid
        rm -f gschemas.compiled
-       rm -f resources.c
+       rm -f $(BUILT_SRC)
        rm -f $(OBJS)
        rm -f exampleapp
index 418cc4d18bfb467d203d8d5748779ba59c3c39d5..eb9cff4c3c540dead64d5eb7246fd354a0471026 100644 (file)
@@ -1,13 +1,14 @@
-CC = gcc
+CC ?= gcc
 PKGCONFIG = $(shell which pkg-config)
-CFLAGS = `$(PKGCONFIG) --cflags gtk+-3.0`
-LIBS = `$(PKGCONFIG) --libs gtk+-3.0`
-GLIB_COMPILE_RESOURCES = `$(PKGCONFIG) --variable=glib_compile_resources gio-2.0`
-GLIB_COMPILE_SCHEMAS = `$(PKGCONFIG) --variable=glib_compile_schemas gio-2.0`
+CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
+LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
+GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
+GLIB_COMPILE_SCHEMAS = $(shell $(PKGCONFIG) --variable=glib_compile_schemas gio-2.0)
 
-SRC = resources.c exampleapp.c exampleappwin.c exampleappprefs.c main.c
+SRC = exampleapp.c exampleappwin.c exampleappprefs.c main.c
+BUILT_SRC = resources.c
 
-OBJS = $(SRC:.c=.o)
+OBJS = $(BUILT_SRC:.c=.o) $(SRC:.c=.o)
 
 all: exampleapp
 
@@ -29,6 +30,6 @@ exampleapp: $(OBJS) gschemas.compiled
 clean:
        rm -f org.gtk.exampleapp.gschema.valid
        rm -f gschemas.compiled
-       rm -f resources.c
+       rm -f $(BUILT_SRC)
        rm -f $(OBJS)
        rm -f exampleapp
index 0561f77ca85046bff0913537cc8149257a7b523f..917e3c70f0cc0cef91fd5e27a56ec41d72a18218 100644 (file)
@@ -1,13 +1,14 @@
-CC = gcc
+CC ?= gcc
 PKGCONFIG = $(shell which pkg-config)
-CFLAGS = `$(PKGCONFIG) --cflags gtk+-3.0`
-LIBS = `$(PKGCONFIG) --libs gtk+-3.0`
-GLIB_COMPILE_RESOURCES = `$(PKGCONFIG) --variable=glib_compile_resources gio-2.0`
-GLIB_COMPILE_SCHEMAS = `$(PKGCONFIG) --variable=glib_compile_schemas gio-2.0`
+CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
+LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
+GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
+GLIB_COMPILE_SCHEMAS = $(shell $(PKGCONFIG) --variable=glib_compile_schemas gio-2.0)
 
-SRC = resources.c exampleapp.c exampleappwin.c exampleappprefs.c main.c
+SRC = exampleapp.c exampleappwin.c exampleappprefs.c main.c
+BUILT_SRC = resources.c
 
-OBJS = $(SRC:.c=.o)
+OBJS = $(BUILT_SRC:.c=.o) $(SRC:.c=.o)
 
 all: exampleapp
 
@@ -29,6 +30,6 @@ exampleapp: $(OBJS) gschemas.compiled
 clean:
        rm -f org.gtk.exampleapp.gschema.valid
        rm -f gschemas.compiled
-       rm -f resources.c
+       rm -f $(BUILT_SRC)
        rm -f $(OBJS)
        rm -f exampleapp
index 0561f77ca85046bff0913537cc8149257a7b523f..917e3c70f0cc0cef91fd5e27a56ec41d72a18218 100644 (file)
@@ -1,13 +1,14 @@
-CC = gcc
+CC ?= gcc
 PKGCONFIG = $(shell which pkg-config)
-CFLAGS = `$(PKGCONFIG) --cflags gtk+-3.0`
-LIBS = `$(PKGCONFIG) --libs gtk+-3.0`
-GLIB_COMPILE_RESOURCES = `$(PKGCONFIG) --variable=glib_compile_resources gio-2.0`
-GLIB_COMPILE_SCHEMAS = `$(PKGCONFIG) --variable=glib_compile_schemas gio-2.0`
+CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
+LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
+GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
+GLIB_COMPILE_SCHEMAS = $(shell $(PKGCONFIG) --variable=glib_compile_schemas gio-2.0)
 
-SRC = resources.c exampleapp.c exampleappwin.c exampleappprefs.c main.c
+SRC = exampleapp.c exampleappwin.c exampleappprefs.c main.c
+BUILT_SRC = resources.c
 
-OBJS = $(SRC:.c=.o)
+OBJS = $(BUILT_SRC:.c=.o) $(SRC:.c=.o)
 
 all: exampleapp
 
@@ -29,6 +30,6 @@ exampleapp: $(OBJS) gschemas.compiled
 clean:
        rm -f org.gtk.exampleapp.gschema.valid
        rm -f gschemas.compiled
-       rm -f resources.c
+       rm -f $(BUILT_SRC)
        rm -f $(OBJS)
        rm -f exampleapp
index 0561f77ca85046bff0913537cc8149257a7b523f..917e3c70f0cc0cef91fd5e27a56ec41d72a18218 100644 (file)
@@ -1,13 +1,14 @@
-CC = gcc
+CC ?= gcc
 PKGCONFIG = $(shell which pkg-config)
-CFLAGS = `$(PKGCONFIG) --cflags gtk+-3.0`
-LIBS = `$(PKGCONFIG) --libs gtk+-3.0`
-GLIB_COMPILE_RESOURCES = `$(PKGCONFIG) --variable=glib_compile_resources gio-2.0`
-GLIB_COMPILE_SCHEMAS = `$(PKGCONFIG) --variable=glib_compile_schemas gio-2.0`
+CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
+LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
+GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
+GLIB_COMPILE_SCHEMAS = $(shell $(PKGCONFIG) --variable=glib_compile_schemas gio-2.0)
 
-SRC = resources.c exampleapp.c exampleappwin.c exampleappprefs.c main.c
+SRC = exampleapp.c exampleappwin.c exampleappprefs.c main.c
+BUILT_SRC = resources.c
 
-OBJS = $(SRC:.c=.o)
+OBJS = $(BUILT_SRC:.c=.o) $(SRC:.c=.o)
 
 all: exampleapp
 
@@ -29,6 +30,6 @@ exampleapp: $(OBJS) gschemas.compiled
 clean:
        rm -f org.gtk.exampleapp.gschema.valid
        rm -f gschemas.compiled
-       rm -f resources.c
+       rm -f $(BUILT_SRC)
        rm -f $(OBJS)
        rm -f exampleapp